var productxTable;
function getProductxList() {
    if (typeof productxTable !== 'undefined') {
    	productxTable.fnPageChange('first');
        return;
    }
    var i = 1;
    productxTable = $("#ProductxList").DataTable({
        "sAjaxSource": _path + "/ytwhproduct/queryByPage",
        "fnServerParams": function (aoData) {
            aoData.push(
                { "name": "columnId", "value": $("#columnId").val() || $("#pid").val() },
                { "name": "status", "value": $("#status").val() },
                { "name": "fromDate", "value": $("#fromDate").val() },
                { "name": "toDate", "value": $("#toDate").val() },
                { "name": "keyType", "value": $("#keyType").val() },
                { "name": "keywords", "value": $("#keywords").val() }
            );
        },
        "sServerMethod": "POST",
        "sAjaxDataProp": "dataList",
        "fnCreatedRow": function () {
            i++;
        },
        "fnPreDrawCallback": function () {
            i = 1;
        },
        "aoColumns": [
            { "sTitle": "序号", "sWidth": "2%",
                "mData": function () {
                    return i;
                }
            },
            { "sTitle": "产品名称", "mData": "title", "sWidth": "10%" },
            { "sTitle": "分类", "mData": "cv.value0", "sWidth": "10%" },
            { "sTitle": "状态", "mData": "status", "sWidth": "10%",
                "mRender": function (data) {
                    var status = '';
                    switch (data) {
                        case '0':
                            status = '已发布';
                            break;
                        case '1':
                            status = '已下架';
                            break;
                        case '2':
                            status = '审核中';
                            break;
                        case '3':
                            status = '审核不通过';
                            break;
                        default :
                            status = '有效';
                            break;
                    }
                    return status;
                }
            },
            { "sTitle": "发布时间", "mData": "createTime", "sWidth": "10%" },
            { "sTitle": "操作", "sWidth": "10%",
                "mData": function (data) {
                    var status = '<a href="' + _path + '/ytwhproduct/edit/' + data.id + '" class="btn default btn-xs purple"><i class="fa fa-edit" title="编辑"></i></a>';
                    status += '<a href="javascript:check('+ data.id+ ');"  class="btn default btn-xs red"><i class="fa fa-trash-o" title="删除"></i></a>';
                    return status;
                }
            }
        ]
    });
}

function check(id){
	layer.confirm('您确定要删除吗？', function(){
			location.href = _path + "/ytwhproduct/del/" + id;
		}, function(){
		
		});
}